$OpenBSD: patch-cmake_modules_FindTaglib_cmake,v 1.2 2014/04/29 09:39:32 zhuk Exp $
Fix Taglib detection, avoiding putting -L/usr/local/lib everywhere.
--- cmake/modules/FindTaglib.cmake.orig	Wed Jan 29 13:36:39 2014
+++ cmake/modules/FindTaglib.cmake	Thu Mar 13 20:28:07 2014
@@ -10,76 +10,30 @@
 # Redistribution and use is allowed according to the terms of the BSD license.
 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
 
+find_package(PkgConfig)
+include(FindLibraryWithDebug)
+include(FindPackageHandleStandardArgs)
+
 if(NOT TAGLIB_MIN_VERSION)
   set(TAGLIB_MIN_VERSION "1.4")
 endif(NOT TAGLIB_MIN_VERSION)
 
-if(NOT WIN32)
-    find_program(TAGLIBCONFIG_EXECUTABLE NAMES taglib-config PATHS
-       ${BIN_INSTALL_DIR}
-    )
-endif(NOT WIN32)
+pkg_check_modules(PC_TAGLIB taglib>=${TAGLIB_MIN_VERSION})
 
-#reset vars
-set(TAGLIB_LIBRARIES)
-set(TAGLIB_CFLAGS)
-
-# if taglib-config has been found
-if(TAGLIBCONFIG_EXECUTABLE)
-
-  exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --version RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_VERSION)
-
-  if(TAGLIB_VERSION STRLESS "${TAGLIB_MIN_VERSION}")
-     message(STATUS "TagLib version not found: version searched :${TAGLIB_MIN_VERSION}, found ${TAGLIB_VERSION}")
-     set(TAGLIB_FOUND FALSE)
-  else(TAGLIB_VERSION STRLESS "${TAGLIB_MIN_VERSION}")
-
-     exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --libs RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_LIBRARIES)
-
-     exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --cflags RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_CFLAGS)
-
-     if(TAGLIB_LIBRARIES AND TAGLIB_CFLAGS)
-        set(TAGLIB_FOUND TRUE)
-        message(STATUS "Found taglib: ${TAGLIB_LIBRARIES}")
-     endif(TAGLIB_LIBRARIES AND TAGLIB_CFLAGS)
-     string(REGEX REPLACE " *-I" ";" TAGLIB_INCLUDES "${TAGLIB_CFLAGS}")
-  endif(TAGLIB_VERSION STRLESS "${TAGLIB_MIN_VERSION}") 
-  mark_as_advanced(TAGLIB_CFLAGS TAGLIB_LIBRARIES TAGLIB_INCLUDES)
-
-else(TAGLIBCONFIG_EXECUTABLE)
-
-  include(FindLibraryWithDebug)
-  include(FindPackageHandleStandardArgs)
-
-  find_path(TAGLIB_INCLUDES
+find_path(TAGLIB_INCLUDES
     NAMES
-    tag.h
-    PATH_SUFFIXES taglib
-    PATHS
-    ${KDE4_INCLUDE_DIR}
-    ${INCLUDE_INSTALL_DIR}
-  )
+    taglib/tag.h
+    HINTS ${PC_TAGLIB_INCLUDE_DIRS}
+    )
 
-  find_library_with_debug(TAGLIB_LIBRARIES
+find_library_with_debug(TAGLIB_LIBRARY
     WIN32_DEBUG_POSTFIX d
     NAMES tag
-    PATHS
-    ${KDE4_LIB_DIR}
-    ${LIB_INSTALL_DIR}
-  )
-  
-  find_package_handle_standard_args(Taglib DEFAULT_MSG 
-                                    TAGLIB_INCLUDES TAGLIB_LIBRARIES)
-endif(TAGLIBCONFIG_EXECUTABLE)
+    HINTS ${PC_TAGLIB_LIBRARY_DIRS}
+    )
 
-
-if(TAGLIB_FOUND)
-  if(NOT Taglib_FIND_QUIETLY AND TAGLIBCONFIG_EXECUTABLE)
-    message(STATUS "Taglib found: ${TAGLIB_LIBRARIES}")
-  endif(NOT Taglib_FIND_QUIETLY AND TAGLIBCONFIG_EXECUTABLE)
-else(TAGLIB_FOUND)
-  if(Taglib_FIND_REQUIRED)
-    message(FATAL_ERROR "Could not find Taglib")
-  endif(Taglib_FIND_REQUIRED)
-endif(TAGLIB_FOUND)
-
+set(TAGLIB_LIBRARIES     ${TAGLIB_LIBRARY})
+set(TAGLIB_INCLUDE_DIRS  ${TAGLIB_INCLUDES})
+  
+find_package_handle_standard_args(Taglib DEFAULT_MSG 
+                                  TAGLIB_INCLUDE_DIRS TAGLIB_LIBRARIES)
